home *** CD-ROM | disk | FTP | other *** search
- program TestClone;
-
- uses CRT,Objects,UObj;
-
- type
- pAncestor = ^Ancestor;
- Ancestor = object(TObj)
- procedure WhoAmI; virtual;
- end;
-
- procedure Ancestor.WhoAmI;
- begin
- Writeln('Ancestor');
- end;
-
- type
- pChild = ^Child;
- Child = object(Ancestor)
- procedure WhoAmI; virtual;
- end;
-
- procedure Child.WhoAmI;
- begin
- Writeln('Child');
- end;
-
- var
- theAncestor : pAncestor;
- theChild : pChild;
- theClone : pAncestor;
-
- begin
- ClrScr;
-
- New(theAncestor,Bind);
- New(theChild,Bind);
-
- theClone := theChild^.Clone;
- theChild^.WhoAmI;
- theClone^.WhoAmI;
- theClone^.Free;
-
- writeln;
-
- theClone := theAncestor^.Clone;
- theAncestor^.WhoAmI;
- theClone^.WhoAmI;
- theClone^.Free;
-
- theAncestor^.Free;
- theChild^.Free;
- end.